package org.itboys.mobile.service.mongo.mobile;

import org.itboys.mobile.common.SundayCommonConstants;
import org.itboys.mobile.entity.mongo.MemberLevel;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by liu on 2017/10/30.
 */
@Service
public class SundayMobileMemberLevelService extends BaseService<MemberLevel,Long>{

    @Resource(name = "adminDS")
    private MongoDataSource dictDataSource;

    protected MongoDataSource getMongoDataSource(){
        return dictDataSource;
    }
    protected Class<MemberLevel> getEntityClass(){return MemberLevel.class;}

    public MemberLevel getByType(Integer type){
        MemberLevel level = null;
        switch (type){
            case 1:
                level = getByField("code", SundayCommonConstants.MemberLevelCode.MEMBER);
                break;
            case 2:
                level = getByField("code",SundayCommonConstants.MemberLevelCode.PARTNER);
                break;
        }
        return level;
    }
}
